<template>
    <div class="app-container">
      <el-table v-loading="loading" :data="drugstoreList" @selection-change="handleSelectionChange">
        <el-table type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="rugstoreId" />
        <el-table-column label="库房" align="center" prop="warehouseName" />
      <el-table-column label="名称" align="center" prop="drugstoreName" />
      <el-table-column label="供货商" align="center" prop="supplierName" />
      <el-table-column label="经办人" align="center" prop="skullName" />
      <el-table-column label="单位" align="center" prop="unitName" />
      <el-table-column label="批发价" align="center" prop="tradePrice" />
      <el-table-column label="售价" align="center" prop="sellingPrice" />
      <el-table-column label="产地" align="center" prop="areaName" />
      <el-table-column label="生产日期" align="center" prop="produceDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.produceDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="有效日期" align="center" prop="validDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.validDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="批号" align="center" prop="batch" />
      <el-table-column label="类型" align="center" prop="typeName" />
      <el-table-column label="数量" align="center" prop="drugstorenum" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleDelete(scope.row)"
              v-hasPermi="['warehouse:drugstore:remove']"
            >已处理</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </template>
  
  <script>
  import { listDrugstore, delDrugstore} from "@/api/warehouse/drugstore";
  
  export default {
    name: "Drugstore",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 药品库存表格数据
        drugstoreList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 表单参数
        form: {},
        // 查询参数
        // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询药品库存列表 */
      getList() {
        this.loading = true;
        listDrugstore(this.queryParams).then(response => {
          this.drugstoreList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const rugstoreIds = row.drugstoreName || this.ids;
        this.$modal.confirm('真的要删除【' + rugstoreIds + '】这个药品吗?').then(function() {
          return delDrugstore(rugstoreIds);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
    }
  };
  </script>
  